﻿using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.ViewManagement;

namespace JiveMessenger.Utilities
{
    public static class StatusBarHelper
    {
        public static async Task ShowStatusBarProgress(string message = "")
        {
#if WINDOWS_PHONE_APP
            await DispatcherHelper.RunAsync(async () =>
                {
                    StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
                    progressbar.Text = message;
                    progressbar.ProgressValue = 0;
                    Messenger.Default.Send(new NotificationMessage("ShowProgressbar"));
                  await progressbar.ShowAsync();
                });
#endif
        }
        public static void UpdateStatusBarProgress(double value)
        {
#if WINDOWS_PHONE_APP
            DispatcherHelper.RunAsync(() =>
    {
      //  StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
       // progressbar.ProgressValue = value;
        Messenger.Default.Send(new NotificationMessage<double>(value, "SetStatusBarValue"));
    });
#endif
        }

        public static void HideStatusBarProgress()
        {
#if WINDOWS_PHONE_APP
            DispatcherHelper.RunAsync(() =>
    {
        StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
        progressbar.HideAsync();
        Messenger.Default.Send(new NotificationMessage("HideProgressbar"));
    });
#endif
        }
    }
}
